import {storage} from "/@/utils/cache";
import {CacheKeyEnum} from "/@/enums/CacheEnum";
import {UserInfo} from "/#/store";


export function  getToken(){
    return storage.get(CacheKeyEnum.TOKEN);
}

export function setToken(token:string){
    storage.set(CacheKeyEnum.TOKEN,token);
}

export function removeToken(){
    storage.remove(CacheKeyEnum.TOKEN);
}

export function getUserInfoCache(){
    return storage.get(CacheKeyEnum.USER_INFO);
}

export function setUserInfoCache(userInfo:UserInfo){
   storage.set(CacheKeyEnum.USER_INFO,userInfo);
}

export function removeUserInfoCache(){
    storage.remove(CacheKeyEnum.USER_INFO);
}

export function getRoleListCache(){
    return storage.get(CacheKeyEnum.ROLE_LIST);
}

export function setRoleListCache(roleList:[]){
   storage.set(CacheKeyEnum.ROLE_LIST,roleList);
}

export function removeRoleListCache(){
    storage.remove(CacheKeyEnum.ROLE_LIST);
}

export function setAuthCache(key:string,value:any){
    storage.set(key,value)
}

export function getAuthCache(key:string){
    return storage.get(key)
}

export const isLogin = !!getToken()

